#include<bits/stdc++.h>
#define N 200010
using namespace std;
int l[N],r[N],pre[N],nxt[N],a[N],n,used;
int qr(int x)
{
	if(a[nxt[x]]!=a[x])return nxt[x];
	else return nxt[x]=qr(nxt[x]);
}
int ql(int x)
{
	if(a[pre[x]]!=a[x])return pre[x];
	else return pre[x]=ql(pre[x]);
}
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	a[0]=a[n+1]=-1;nxt[n+1]=1919810;nxt[0]=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		l[i]=r[i]=i;
		pre[i]=i-1;
		nxt[i]=i+1;
	}
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1])
			l[i]=i-1,pre[i]=pre[i-1];
	for(int i=n-1;i;i--)
		if(a[i]==a[i+1])
			r[i]=i+1,nxt[i]=nxt[i+1];
	while(used<n)
	{
		for(int i=nxt[0];i<=n;i=qr(i))
		{
			printf("%d ",i);
			used++;
			if(r[i]!=i)
			{
				nxt[ql(i)]=r[i];
				pre[qr(i)]=r[i];
				pre[r[i]]=pre[ql(i)];
			}
			else
			{
				int x=ql(i),y=qr(i);
				pre[y]=x;nxt[x]=y;
				if(a[x]==a[y])r[x]=y,l[y]=x;
			}
		}
		printf("\n");
	}
}
